package exportExcel;

import java.io.FileOutputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.util.CollectionUtils;
import org.testng.annotations.Test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bbcare.comm.AppException;
import com.bbcare.comm.Constants;
import com.bbcare.comm.DateUtil;
import com.bbcare.comm.ErrorCode;
import com.bbcare.comm.ToolUtils;
import com.bbcare.followup.plat.entity.PatientTask;
import com.bbcare.followup.plat.service.IPatientService;
import com.bbcare.followup.plat.store.ibatis.IFollowEvaluationDAO;
import com.bbcare.followup.plat.store.ibatis.IPatientTaskDAO;

/**
 *
 * @name:         ExportBaileyExcel.java
 * @createTime:   2017年12月5日
 * @description:  批量导出贝利网络版 数据
 * @modify:
 *
 */
@ContextConfiguration(locations = { "classpath*:/ibatis-config.xml",
		"classpath*:/spring-mvc.xml","classpath*:/spring-mybatis.xml"
		})
public class ExportBaileyExcel extends AbstractTestNGSpringContextTests {

	@Autowired
	IFollowEvaluationDAO followEvaluationDao;

	@Autowired
    private IPatientService patientSerivce;

	 @Autowired
    private IPatientTaskDAO patientTaskDao;

	@Test
	public void service() throws Exception {
		//查询患者 + 记录
		Map<String,Object> paramMap = new HashMap<String,Object>();
		List<String> queueList = new ArrayList<String>();
		String queueId ="12SHYFY000000001";//一妇婴:12SHYFY000000001  吴江 ：12SHYFY000000019
		String tenantId ="SHYFY0001";
		String deptId="shyFyJdept10001";//一妇婴:shyFyJdept10001  吴江 ：shyFyJdept10019
		String shequ="18862163677";

		queueList.add(queueId);
		paramMap.put("examinationPaperName","BaileyScreening");
		paramMap.put("queueIdIn",queueList);
		paramMap.put("tenantId",tenantId);

		List<Map<String,Object>> records = followEvaluationDao.selectEvaluationResultAll(paramMap);

		//查询患者建档资料
		if(!CollectionUtils.isEmpty(records)){
			for(int i =0 ;i<records.size();i++){
//				String userId = records.get(i).get("userId").toString();
				String ptSchemeId= records.get(i).get("ptSchemeId").toString();

		        paramMap.clear();
		        paramMap.put("seqNo", Constants.TASK_SEQ_FOR_INIT);
		        paramMap.put("ptSchemeId",ptSchemeId);
				// 查询taskid
				List<PatientTask> taskList = patientTaskDao.select(paramMap);
				String taskId ="";
				if (!CollectionUtils.isEmpty(taskList)) {
					taskId = taskList.get(0).getId();
				}

				paramMap.clear();
				paramMap.put("tenantId", tenantId);
				paramMap.put("groupType", Constants.TENANT_GROUP_TYPE_FOR_MULCENTER);
				paramMap.put("rootGroupId", deptId);
		        if (null == queueId || "".equals(queueId)) {
		            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，未传入队列id或值为空！"));
		        }
		        paramMap.put("taskId", taskId);
		        paramMap.put("queueId", queueId);
		        Map<String, Object> retMap = patientSerivce.qryPatientContentList(paramMap);
//		        System.out.println(retMap.get("values").toString());
		        JSONObject questiones =JSONObject.parseObject(JSON.toJSONString(retMap.get("values")));
		        String birthWeight = questiones.getString("Pub2200001");
		        String motherBitrhday = questiones.getString("Pub2200004");
		        String idiccid = questiones.getString("Pub2200003");

		        int weight = Integer.parseInt(birthWeight);
		        float weightf = (float)weight/1000;
		        records.get(i).put("birthWeight",weightf);
		        records.get(i).put("motherBitrhday",motherBitrhday);
		        records.get(i).put("idiccid",idiccid);

		        if(null == records.get(i).get("testTime")){
			        records.get(i).put("testTime",records.get(i).get("createTime").toString().substring(0,10));
		        }else{
			        records.get(i).put("testTime",records.get(i).get("testTime").toString());
		        }
		        //
		        String score = (String)records.get(i).get("score");
		        String pregnancDayStr = records.get(i).get("pregnancDay").toString();
//		        String expectedDay = records.get(i).get("expectedDay").toString();
		        String birthday  = records.get(i).get("birthday").toString();
		        String testTime = records.get(i).get("testTime").toString();
		        int pregnancDay = Integer.parseInt(pregnancDayStr);
		        records.get(i).put("pregnancWeek",pregnancDay/7);

		        long correctBirth = ToolUtils.getCorrect(birthday, pregnancDay);
		        records.get(i).put("crrectAge", getCommAgeByBirthday(testTime,DateUtil.getDate_8(new Date(correctBirth))));
				int ageMonth = ToolUtils.getAgeMonthByBirthday(testTime,DateUtil.getDate_8(new Date(correctBirth)));
		        records.get(i).put("ageMonth", ageMonth);
		        long day = 	(long)((DateUtil.getDate(testTime).getTime()-correctBirth)/(1000*60*60*24));

		        JSONObject json = JSONObject.parseObject(score);
		        int bigAction = json.getIntValue("bigAction"); //大动作
		        int express = json.getIntValue("express");//语言表达
		        int fineMotor = json.getIntValue("fineMotor"); //精细
		        int understand = json.getIntValue("understand");//语言理解
		        int cognitive = json.getIntValue("cognitive");//语言理解

		        records.get(i).put("bigAction", bigAction);
		        records.get(i).put("express", express);
		        records.get(i).put("fineMotor", fineMotor);
		        records.get(i).put("understand", understand);
		        records.get(i).put("cognitive", cognitive);

		        String WARN="边缘",NORMAL="无明显异常",DANGEROUS="存在落后风险";
		        String cognitiveResult  ="";
		        String expressResult  ="";
		        String fineMotorResult  ="";
		        String bigActionResult  ="";
		        String understandResult  ="";

		        if (16 <= day && day <= 3 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 2) cognitiveResult = WARN;
		            if (3 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 == understand)    understandResult = DANGEROUS;
		            if (0 < understand && understand <= 2) understandResult = WARN;
		            if (3 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 1) expressResult = WARN;
		            if (2 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 2) fineMotorResult = WARN;
		            if (3 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 2) bigActionResult = WARN;
		            if (3 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (3 * 30 + 16 <= day && day <= 6 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 3) cognitiveResult = DANGEROUS;
		            if (4 <= cognitive && cognitive <= 6) cognitiveResult = WARN;
		            if (7 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 3)    understandResult = DANGEROUS;
		            if (4 <= understand && understand <= 5) understandResult = WARN;
		            if (6 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 2) expressResult = DANGEROUS;
		            if (3 <= express && express <= 4) expressResult = WARN;
		            if (5 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 3) fineMotorResult = DANGEROUS;
		            if (4 <= fineMotor && fineMotor <= 6) fineMotorResult = WARN;
		            if (7 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 4) bigActionResult = DANGEROUS;
		            if (5 <= bigAction && bigAction <= 6) bigActionResult = WARN;
		            if (7 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (6 * 30 + 16 <= day && day <= 9 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 6) cognitiveResult = DANGEROUS;
		            if (7 <= cognitive && cognitive <= 9) cognitiveResult = WARN;
		            if (10 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 5)    understandResult = DANGEROUS;
		            if (6 <= understand && understand <= 7) understandResult = WARN;
		            if (8 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 3) expressResult = DANGEROUS;
		            if (4 <= express && express <= 5) expressResult = WARN;
		            if (6 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 6) fineMotorResult = DANGEROUS;
		            if (7 <= fineMotor && fineMotor <= 8) fineMotorResult = WARN;
		            if (9 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 7) bigActionResult = DANGEROUS;
		            if (8 <= bigAction && bigAction <= 10) bigActionResult = WARN;
		            if (11 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (9 * 30 + 16 <= day && day <= 12 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 9) cognitiveResult = DANGEROUS;
		            if (10 <= cognitive && cognitive <= 13) cognitiveResult = WARN;
		            if (14 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 6)    understandResult = DANGEROUS;
		            if (7 <= understand && understand <= 9) understandResult = WARN;
		            if (10 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 4) expressResult = DANGEROUS;
		            if (5 <= express && express <= 8) expressResult = WARN;
		            if (9 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 8) fineMotorResult = DANGEROUS;
		            if (9 <= fineMotor && fineMotor <= 10) fineMotorResult = WARN;
		            if (11 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 10) bigActionResult = DANGEROUS;
		            if (11 <= bigAction && bigAction <= 12) bigActionResult = WARN;
		            if (13 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (12 * 30 + 16 <= day && day <= 18 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 13) cognitiveResult = DANGEROUS;
		            if (14 <= cognitive && cognitive <= 16) cognitiveResult = WARN;
		            if (17 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 9)    understandResult = DANGEROUS;
		            if (10 <= understand && understand <= 11) understandResult = WARN;
		            if (12 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 9) expressResult = DANGEROUS;
		            if (10 <= express && express <= 12) expressResult = WARN;
		            if (13 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 10) fineMotorResult = DANGEROUS;
		            if (11 <= fineMotor && fineMotor <= 13) fineMotorResult = WARN;
		            if (14 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 12) bigActionResult = DANGEROUS;
		            if (13 <= bigAction && bigAction <= 16) bigActionResult = WARN;
		            if (17 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (18 * 30 + 16 <= day && day <= 24 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 16) cognitiveResult = DANGEROUS;
		            if (17 <= cognitive && cognitive <= 20) cognitiveResult = WARN;
		            if (21 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 11)    understandResult = DANGEROUS;
		            if (12 <= understand && understand <= 15) understandResult = WARN;
		            if (16 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 11) expressResult = DANGEROUS;
		            if (12 <= express && express <= 15) expressResult = WARN;
		            if (16 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 11) fineMotorResult = DANGEROUS;
		            if (12 <= fineMotor && fineMotor <= 16) fineMotorResult = WARN;
		            if (17 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 16) bigActionResult = DANGEROUS;
		            if (17 <= bigAction && bigAction <= 18) bigActionResult = WARN;
		            if (19 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (24 * 30 + 16 <= day && day <= 30 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 20) cognitiveResult = DANGEROUS;
		            if (21 <= cognitive && cognitive <= 24) cognitiveResult = WARN;
		            if (25 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 12)    understandResult = DANGEROUS;
		            if (13 <= understand && understand <= 18) understandResult = WARN;
		            if (19 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 12) expressResult = DANGEROUS;
		            if (13 <= express && express <= 18) expressResult = WARN;
		            if (19 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 14) fineMotorResult = DANGEROUS;
		            if (15 <= fineMotor && fineMotor <= 18) fineMotorResult = WARN;
		            if (19 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 18) bigActionResult = DANGEROUS;
		            if (19 <= bigAction && bigAction <= 21) bigActionResult = WARN;
		            if (22 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (30 * 30 + 16 <= day && day <= 36 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 22) cognitiveResult = DANGEROUS;
		            if (23 <= cognitive && cognitive <= 27) cognitiveResult = WARN;
		            if (28 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 12)    understandResult = DANGEROUS;
		            if (13 <= understand && understand <= 20) understandResult = WARN;
		            if (21 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 14) expressResult = DANGEROUS;
		            if (15 <= express && express <= 20) expressResult = WARN;
		            if (21 <= express && express <= 24) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 17) fineMotorResult = DANGEROUS;
		            if (18 <= fineMotor && fineMotor <= 22) fineMotorResult = WARN;
		            if (23 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 18) bigActionResult = DANGEROUS;
		            if (19 <= bigAction && bigAction <= 23) bigActionResult = WARN;
		            if (24 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;

		        } else if (36 * 30 + 16 <= day && day <= 42 * 30 + 15) {
		            if (0 <= cognitive && cognitive <= 24) cognitiveResult = DANGEROUS;
		            if (25 <= cognitive && cognitive <= 31) cognitiveResult = WARN;
		            if (32 <= cognitive && cognitive <= 33) cognitiveResult = NORMAL;

		            if (0 <= understand && understand <= 14)    understandResult = DANGEROUS;
		            if (15 <= understand && understand <= 22) understandResult = WARN;
		            if (23 <= understand && understand <= 24) understandResult = NORMAL;

		            if (0 <= express && express <= 15) expressResult = DANGEROUS;
		            if (16 <= express && express <= 23) expressResult = WARN;
		            if (24 == express) expressResult = NORMAL;

		            if (0 <= fineMotor && fineMotor <= 17) fineMotorResult = DANGEROUS;
		            if (18 <= fineMotor && fineMotor <= 25) fineMotorResult = WARN;
		            if (26 <= fineMotor && fineMotor <= 27) fineMotorResult = NORMAL;

		            if (0 <= bigAction && bigAction <= 20) bigActionResult = DANGEROUS;
		            if (21 <= bigAction && bigAction <= 26) bigActionResult = WARN;
		            if (27 <= bigAction && bigAction <= 28) bigActionResult = NORMAL;
		        }

		        records.get(i).put("cognitiveResult", cognitiveResult);
		        records.get(i).put("expressResult", expressResult);
		        records.get(i).put("fineMotorResult", fineMotorResult);
		        records.get(i).put("bigActionResult", bigActionResult);
		        records.get(i).put("understandResult", understandResult);

		        String group ="";
		        if(ageMonth>=1 &&ageMonth<=6){
		        	group = "A";
		        }else if(ageMonth>=7 && ageMonth<=12){
		        	group = "B";
		        }else if(ageMonth>=13 && ageMonth<=24){
		        	group = "C";
		        }else if(ageMonth>=25 && ageMonth<=42){
		        	group = "D";
		        }
		        records.get(i).put("group", group);
			}
		}

		//创建HSSFWorkbook对象
		HSSFWorkbook wb = new HSSFWorkbook();
		//创建HSSFSheet对象
		HSSFSheet sheet = wb.createSheet("sheet0");
		//创建HSSFRow对象
		HSSFRow row = sheet.createRow(0);
		//创建HSSFCell对象
		HSSFCell cell=row.createCell(0);
		//设置单元格的值
		cell.setCellValue("贝利账号");
		cell = row.createCell(1);
		cell.setCellValue("姓名");
		cell = row.createCell(2);
		cell.setCellValue("出生日期");
		cell = row.createCell(3);
		cell.setCellValue("出生体重");
		cell = row.createCell(4);
		cell.setCellValue("纠正胎龄(放的生日)");
		cell = row.createCell(5);
		cell.setCellValue("母亲姓名");
		cell = row.createCell(6);
		cell.setCellValue("母亲生日");
		cell = row.createCell(7);
		cell.setCellValue("母亲身份证后四位");
		cell = row.createCell(8);
		cell.setCellValue("认知能力");
		cell = row.createCell(9);
		cell.setCellValue("语言理解");
		cell = row.createCell(10);
		cell.setCellValue("语言表达");
		cell = row.createCell(11);
		cell.setCellValue("精细动作");
		cell = row.createCell(12);
		cell.setCellValue("大动作");
		cell = row.createCell(13);
		cell.setCellValue("所属社区");
		cell = row.createCell(14);
		cell.setCellValue("问卷日期");
		cell = row.createCell(15);
		cell.setCellValue("孕周");
		cell = row.createCell(16);
		cell.setCellValue("年龄");
		cell = row.createCell(17);
		cell.setCellValue("年龄（月）");
		cell = row.createCell(18);
		cell.setCellValue("分组");

		cell = row.createCell(19);
		cell.setCellValue("认知能力等级");
		cell = row.createCell(20);
		cell.setCellValue("语言理解等级");
		cell = row.createCell(21);
		cell.setCellValue("语言表达等级");
		cell = row.createCell(22);
		cell.setCellValue("精细运动等级");
		cell = row.createCell(23);
		cell.setCellValue("大动作等级");

		cell = row.createCell(24);
		cell.setCellValue("孕周(天)");
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式

		for (int i = 0; i < records.size(); i++)
		{
			row = sheet.createRow((int) i + 1);
			Map<String,Object> map = records.get(i);
			// 第四步，创建单元格，并设置值
			row.createCell(0).setCellValue(map.get("phoneNum").toString());
			row.createCell(1).setCellValue(map.get("userName").toString());
			row.createCell(2).setCellValue(map.get("birthday").toString());
			row.createCell(3).setCellValue(map.get("birthWeight").toString());
			row.createCell(4).setCellValue(map.get("birthday").toString());
			row.createCell(5).setCellValue("");
			row.createCell(6).setCellValue(map.get("motherBitrhday").toString());
			row.createCell(7).setCellValue(map.get("idiccid").toString());
			row.createCell(8).setCellValue(map.get("cognitive").toString());
			row.createCell(9).setCellValue(map.get("understand").toString());
			row.createCell(10).setCellValue(map.get("express").toString());
			row.createCell(11).setCellValue(map.get("fineMotor").toString());
			row.createCell(12).setCellValue(map.get("bigAction").toString());
			row.createCell(13).setCellValue(shequ);
			row.createCell(14).setCellValue(map.get("testTime").toString());
			row.createCell(15).setCellValue(map.get("pregnancWeek").toString());
			row.createCell(16).setCellValue(map.get("crrectAge").toString());
			row.createCell(17).setCellValue(map.get("ageMonth").toString());
			row.createCell(18).setCellValue(map.get("group").toString());

			row.createCell(19).setCellValue(map.get("cognitiveResult").toString());
			row.createCell(20).setCellValue(map.get("understandResult").toString());
			row.createCell(21).setCellValue(map.get("expressResult").toString());
			row.createCell(22).setCellValue(map.get("fineMotorResult").toString());
			row.createCell(23).setCellValue(map.get("bigActionResult").toString());

			row.createCell(24).setCellValue(map.get("pregnancDay").toString());
		}

		// 第六步，将文件存到指定位置
		try
		{
			FileOutputStream fout = new FileOutputStream("F://一妇婴贝利档案汇总(新系统).xls");
			wb.write(fout);
			fout.close();
			wb.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}


	}

	 public String getCommAgeByBirthday(String testTime, String birthday) throws ParseException {
	        StringBuilder builder = new StringBuilder();
	        Calendar now = Calendar.getInstance();
	        now.setTime(DateUtil.getDate_8(testTime));

	        Calendar cal = Calendar.getInstance();
	        // int age = 0;
	        if (!now.getTime().before(DateUtil.getDate_8(birthday))) {
	            int yearNow = now.get(Calendar.YEAR);
	            int monthNow = now.get(Calendar.MONTH);
	            int dayOfMonthNow = now.get(Calendar.DAY_OF_MONTH);

	            cal.setTime(DateUtil.getDate_8(birthday));
	            int yearBirth = cal.get(Calendar.YEAR);
	            int monthBirth = cal.get(Calendar.MONTH);
	            int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);

	            int day = dayOfMonthNow - dayOfMonthBirth;
	            int month = monthNow - monthBirth;
	            int year = yearNow - yearBirth;

	            // 按照减法原理，先day相减，不够向month借；然后month相减，不够向year借；最后year相减。

	            if (day < 0) {
	                month -= 1;
	                now.add(Calendar.MONTH, -1);// 得到上一个月，用来得到上个月的天数。
	                day = day + now.getActualMaximum(Calendar.DAY_OF_MONTH);
	            }
	            if (month < 0) {
	                month = (month + 12) % 12;
	                year--;
	            }

	            int week = 0;
	            // 暂时展示 一个单位 岁、或月、周、天


	         // 暂时展示 一个单位 岁、或月、天
	            if (year > 0) {
	                builder.append(year).append("岁");
	            }else{
	            	builder.append("0").append("岁");
	            }
	            if (month > 0 && year >= 0) {
	                builder.append(month).append("月");
	            }else{
	            	builder.append("0").append("月");
	            }
	            if (day > 0 ) {
	            	if (day > 0 && month >= 0 && year >= 0) {
	                    if (day > 7) {// 展示周
	                        week = day / 7;
	                        builder.append(week).append("周");
	                        int daytemp = day % 7;
	                        builder.append(daytemp).append("天");
	                    } else {
	                        builder.append(day).append("天");
	                    }
	            	}
	            } else {
	                builder.append("0").append("天");
	            }
	        } else {
	            builder.append("0").append("天");
	        }
	        return builder.toString();
	    }
}
